package logic

import (
	"context"
	"srv/models/mysql"

	"srv/internal/svc"
	"srv/sesame"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserUpdateLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUserUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserUpdateLogic {
	return &UserUpdateLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UserUpdateLogic) UserUpdate(in *sesame.UserUpdateRequest) (*sesame.UserUpdateResponse, error) {
	// todo: add your logic here and delete this line
	u := mysql.User{}
	err := u.GetUserUpdate(in.UserId, in.Status)
	if err != nil {
		logx.Error("修改失败")
		return nil, err
	}
	return &sesame.UserUpdateResponse{
		Status: true,
	}, nil
}
